import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    sourcemap: false,
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true,
      },
    },
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      store: resolve(resolve(__dirname, 'src/store')),
      '@images': resolve(__dirname, 'src/assets/images'),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        // additionalData: '@import "src/style/index.scss";',
      },
    },
  },
  server: {
    cors: true, // 默认启用并允许任何源
    proxy: {
      '/api': {
        target: 'http://localhost:3300',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
})
